#pragma once

#include<pthread.h>

using namespace std;

class mutex
{
public:
private:
    pthread_mutex_t * _mutex;
public:
    mutex(pthread_mutex_t* mutex)
        :_mutex(mutex)
    {
        //pthread_mutex_init(_mutex,nullptr);
    }

    void lock()
    {
        pthread_mutex_lock(_mutex);
    }
    
    void unlock()
    {
        pthread_mutex_unlock(_mutex);
    }

    ~mutex()
    {
    }
};

class Guard
{
private:
    mutex _lock;
public:
    
    Guard(pthread_mutex_t* lock)
        :_lock(lock)
    {
        _lock.lock();
    }
    ~Guard()
    {
        _lock.unlock();
    }
};




